//
//  SpeedTestProc.h
//  GPUProcessingTesting
//
//  Created by kadlubek47 on 17.06.2013.
//  Copyright (c) 2013 kadlubek47. All rights reserved.
//

#ifndef __GPUProcessingTesting__SpeedTestProc__
#define __GPUProcessingTesting__SpeedTestProc__

#include "OpenCLProcessorBase.h"

#include <sys/stat.h>
#include <vector>

//Speed tester processor
class SpeedTestProc: public OpenCLProcessorBase {
public:
    
    SpeedTestProc();
    ~SpeedTestProc();
    
    /*
        Creates buffers on GPU and sets initial values for 1;
        sets buffers as kernel arguments;
     */
    void setBuffers(unsigned int size);
    /*
        Data is copied into GPU buffer, by that function you set
        values;
     */
    void setDataValue(float value);
    
    void transferDataToGPU();
    void executeTheSimplestKernel();
    void transferDataFromGPU(float* destiny);
    void executeCommands() {
        clFlush(cmdQueue_);
        clFinish(cmdQueue_);
    }
     
private:
    
    //Kernel
    static const char kernelPath_[];
    cl_kernel inOutKernel_;
    void createKernels();
    
    //Buffers
    unsigned int buffersLength_;
    cl_mem inBuffer_, outBuffer_;
    
    float* data_ = NULL;
};



#endif /* defined(__GPUProcessingTesting__SpeedTestProc__) */
